package org.jeecg.modules.screen.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.screen.service.IScreenDemoService;
import org.jeecg.modules.screen.service.IScreenService;
import org.jeecg.modules.screen.utils.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;




import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

 /**
 * @Description: 大屏信息
 * @Author: jeecg-boot
 * @Date:   2020-05-02
 * @Version: V1.0
 */
@Slf4j
@Api(tags="区域信息")
@RestController
@RequestMapping("/screen")
public class ScreenController  {
	@Autowired
	private IScreenService screenService;

	 @Autowired
	 private IScreenDemoService screenDemoService;


	 @Autowired
	 private BaseUtil baseUtil;

	 /**
	  * 大屏数据状态获取
	  * @return
	  */
	 @AutoLog(value = "大屏信息-数据状态获取")
	@ApiOperation(value="大屏信息-数据状态获取", notes="大屏信息-数据状态获取")
	@GetMapping(value = "/queryBgDateState")
	 public Result<?> queryBgDateState(){
		return Result.ok(baseUtil.getSwitch());
	 }

	 /**
	  * 关键词热度To
	  * @return
	  */
	 @AutoLog(value = "大屏信息-关键词热度Top")
	 @ApiOperation(value="大屏信息-关键词热度Top", notes="大屏信息-关键词热度Top")
	 @GetMapping(value = "/queryKeywordTopRank")
	 public Result<?> queryKeywordTopRank(){
		 boolean flag = baseUtil.getSwitch();
		 return Result.ok(!flag?screenService.queryKeywordTopRank():screenDemoService.queryKeywordTopRank());
	 }

	 /**
	  * 爬去文章占比（爬虫）
	  * @return
	  */
	 @AutoLog(value = "大屏信息-爬取文章占比")
	 @ApiOperation(value="大屏信息-爬取文章占比", notes="大屏信息-爬取文章占比")
	 @GetMapping(value = "/querySpiderDis")
	 public Result<?> querySpiderDis(){

		boolean flag = baseUtil.getSwitch();
	 	return Result.ok(!flag?screenService.querySpiderDis():screenDemoService.querySpiderDis());
	 }


	 /**
	  * 实时爬取文章
	  * @return
	  */
	 @AutoLog(value = "大屏信息-实时爬取文章")
	 @ApiOperation(value="大屏信息-实时爬取文章", notes="大屏信息-实时爬取文章")
	 @GetMapping(value = "/querySpiderArticle")
	 public Result<?> querySpiderArticle(){
		 boolean flag = baseUtil.getSwitch();

		 return Result.ok(!flag?screenService.querySpiderArticle():screenDemoService.querySpiderArticle());

	 }



	 /**
	  * 任务数据纵览
	  * @return
	  */
	 @AutoLog(value = "大屏信息-任务数据纵览")
	 @ApiOperation(value="大屏信息-任务数据纵览", notes="大屏信息-任务数据纵览")
	 @GetMapping(value = "/queryTaskBrief")
	 public Result<?> taskData(){
		 boolean flag = baseUtil.getSwitch();

		 Map<String,Object> dataModel = !flag?screenService.queryTaskBrief():screenDemoService.queryTaskBrief();
		 return Result.ok(dataModel);
	 }


	 /**
	  * 自媒体粉丝排行
	  * @return
	  */
	 @AutoLog(value = "大屏信息-自媒体粉丝排行")
	 @ApiOperation(value="大屏信息-自媒体粉丝排行", notes="大屏信息-任务数据纵览")
	 @GetMapping(value = "/queryThirdPtFans")
	 public Result<?> queryThirdPtFans(){
		 boolean flag = baseUtil.getSwitch();

		 Map<String,Object> dataModel = !flag?screenService.queryThirdPtFans():screenDemoService.queryThirdPtFans();
		 return Result.ok(dataModel);
	 }

	 /**
	  * 自媒体平台名字和id
	  * @return
	  */
	 @AutoLog(value = "大屏信息-自媒体平台名字和id")
	 @ApiOperation(value="大屏信息-自媒体平台名字和id", notes="大屏信息-自媒体平台名字和id")
	 @GetMapping(value = "/queryThirdIdAndName")
	 public Result<?> queryThirdIdAndName(){
		 boolean flag = baseUtil.getSwitch();

		 List<Map<String,Object>> dataModel = !flag?screenService.queryThirdIdAndName():screenDemoService.queryThirdIdAndName();
		 return Result.ok(dataModel);
	 }

	 /**
	  * 获取第三方转发和评论
	  * @return
	  */
	 @AutoLog(value = "大屏信息-获取第三方转发和评论")
	 @ApiOperation(value="大屏信息-获取第三方转发和评论", notes="大屏信息-获取第三方转发和评论")
	 @GetMapping(value = "/queryThirdViewAndForward")
	 public Result<?> queryThirdViewAndForward(@RequestParam(name = "id", required = true) String id){
		 boolean flag = baseUtil.getSwitch();

		 Map<String,Object> dataModel =  !flag?screenService.queryThirdViewAndForward(id):screenDemoService.queryThirdViewAndForward(id);
		 return Result.ok(dataModel);
	 }


	 /**
	  * 获取资讯活跃用户（总）
	  * @return
	  */
	 @AutoLog(value = "大屏信息-获取资讯活跃用户（总）")
	 @ApiOperation(value="大屏信息-获取资讯活跃用户（总）", notes="大屏信息-获取资讯活跃用户（总）")
	 @GetMapping(value = "/queryActiveUserTotal")
	 public Result<?> queryActiveUserTotal(){
		 boolean flag = baseUtil.getSwitch();

		 Integer count = !flag?screenService.queryActiveUserTotal():screenDemoService.queryActiveUserTotal();
		 return Result.ok(count);
	 }

	 /**
	  * 获取资讯活跃用户（分时）
	  * @return
	  */
	 @AutoLog(value = "大屏信息-获取资讯活跃用 分时")
	 @ApiOperation(value="大屏信息-获取资讯活跃用户（分时）", notes="大屏信息-获取资讯活跃用户（分时）")
	 @GetMapping(value = "/queryActiveUserEveryDay")
	 public Result<?> queryActiveUserEveryDay(){
		 boolean flag = baseUtil.getSwitch();

		 Map<String,Object> retMap = !flag?screenService.queryActiveUserEveryDay():screenDemoService.queryActiveUserEveryDay();
		 return Result.ok(retMap);
	 }

	 /**
	  * 资讯app每日访问
	  * @return
	  */
	 @AutoLog(value = "大屏信息-资讯app每日访问")
	 @ApiOperation(value="大屏信息-）资讯app每日访问", notes="大屏信息-资讯app每日访问")
	 @GetMapping(value = "/queryEveryDayViewZX")
	 public Result<?> queryEveryDayViewZX(){
		 boolean flag = baseUtil.getSwitch();

		 Map<String,Object> retMap =!flag?screenService.queryEveryDayViewZX():screenDemoService.queryEveryDayViewZX();
		 return Result.ok(retMap);
	 }


	 /**
	  * 资讯appPV,UV等
	  * @return
	  */
	 @AutoLog(value = "大屏信息-资讯appPV,UV等")
	 @ApiOperation(value="大屏信息-）资讯appPV,UV等", notes="大屏信息-资讯appPV,UV等")
	 @GetMapping(value = "/queryZXBriefData")
	 public Result<?> queryZXBriefData(){
		 boolean flag = baseUtil.getSwitch();
		 Map<String,Object> retMap = !flag?screenService.queryZXBriefData():screenDemoService.queryZXBriefData();
		 return Result.ok(retMap);
	 }


	 /**
	  * 热门评论列表
	  * @return
	  */
	 @AutoLog(value = "大屏信息-热门评论列表")
	 @ApiOperation(value="大屏信息-热门评论列表", notes="大屏信息-热门评论列表")
	 @GetMapping(value = "/queryHotRemark")
	 public Result<?> queryHotRemark(){
		 boolean flag = baseUtil.getSwitch();
		 List<Map<String,Object>> retMap = !flag?screenService.queryHotRemark():screenDemoService.queryHotRemark();
		 return Result.ok(retMap);
	 }


	 /**
	  * 超期任务列表
	  * @return
	  */
	 @AutoLog(value = "大屏信息-超期任务列表")
	 @ApiOperation(value="大屏信息-超期任务列表", notes="大屏信息-超期任务列表")
	 @GetMapping(value = "/queryOdTaskList")
	 public Result<?> queryOdTaskList(){
		 boolean flag = baseUtil.getSwitch();
		 List<Map<String,Object>> retMap = !flag?screenService.queryOdTaskList():screenDemoService.queryOdTaskList();
		 return Result.ok(retMap);
	 }

	 /**
	  * 采编数据根据类型
	  * @return
	  */
	 @AutoLog(value = "大屏信息-采编数据根据类型")
	 @ApiOperation(value="大屏信息-采编数据根据类型", notes="大屏信息-采编数据根据类型")
	 @GetMapping(value = "/queryContentDataByType")
	 public Result<?> queryContentDataByType(){
		 boolean flag = baseUtil.getSwitch();
		 List<Map<String,Object>> retMap = !flag?screenService.queryContentDataByType():screenDemoService.queryContentDataByType();
		 return Result.ok(retMap);
	 }

	 /**
	  * 获取记者列表
	  * @return
	  */
	 @AutoLog(value = "大屏信息-获取记者列表")
	 @ApiOperation(value="大屏信息-获取记者列表", notes="大屏信息-获取记者列表")
	 @GetMapping(value = "/queryJonList")
	 public Result<?> queryJonList(){
		 boolean flag = baseUtil.getSwitch();
		 List<Map<String,Object>> retMap = !flag?screenService.queryJonList():screenDemoService.queryJonList();
		 return Result.ok(retMap);
	 }

	 /**
	  * 排行榜
	  * @return
	  */
	 @AutoLog(value = "大屏信息-排行榜")
	 @ApiOperation(value="大屏信息-排行榜", notes="大屏信息-排行榜")
	 @GetMapping(value = "/rankInfo")
	 public Result<?> rankInfo(){
		 Map<String,Object> retMap = new HashMap<>();
		 //投稿排行
		 List<Map<String,Object>> retMap1 = screenService.querySubmitRank();

		 //引用排行
		 List<Map<String,Object>> retMap2 = screenService.queryRefRank();

		 retMap.put("submitRank",retMap1);
		 retMap.put("refRank",retMap2);
		 return Result.ok(retMap);
	 }

 }
